package com.yy.micro.magic.core.condition;

import com.yy.micro.magic.core.model.RuntimeMetadata;

import org.springframework.stereotype.Component;

/**
 * {@link @Filter}判定匹配的条件。如果在@Filter中没有设置conditions，在变换过程中则会根据condition来判定。
 * 主要适用于复杂的条件判定。正常情况下通过conditions即可满足匹配判定。
 */
public interface FilterCondition extends Condition<RuntimeMetadata> {

    /**
     * 默认False 条件
     */
    @Component
    class FalseFilterCondition implements FilterCondition {

        @Override
        public boolean match(final RuntimeMetadata runtimeMetadata) {
            return false;
        }
    }

    /**
     * 默认True 条件
     */
    @Component
    class TrueFilterCondition implements FilterCondition {

        @Override
        public boolean match(final RuntimeMetadata runtimeMetadata) {
            return true;
        }
    }
}
